package com.hxd.otc.module.convenience.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hxd.otc.R;
import com.hxd.otc.base.BaseAdapter;
import com.hxd.otc.module.convenience.bean.NorGoodsBean;
import com.hxd.otc.utils.ResourceUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by lzy on 2018/12/14 0014.
 * description ${视频类型Adapter}
 */
public class VideoGoodsAdapter extends BaseAdapter<VideoGoodsAdapter.VideoGoodsHolder, NorGoodsBean> {

    private boolean mEnable;

    public VideoGoodsAdapter(Context context) {
        super(context);
    }

    @Override
    protected void onBindHolder(@NonNull VideoGoodsHolder holder, int position) {
        NorGoodsBean item = getItem(position);
        holder.tvFaceValue.setText(item.getGoodsName());
        holder.tvPaymentPrice.setText(ResourceUtil.getString(R.string.sell_price_sub_sub, item.getVolume(), item.getSymbol()));
        holder.itemView.setEnabled(mEnable);
        holder.tvFaceValue.setEnabled(mEnable);
        holder.tvPaymentPrice.setEnabled(mEnable);
    }

    @NonNull
    @Override
    public VideoGoodsHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new VideoGoodsHolder(mInflater.inflate(R.layout.item_prepaid_recharge, parent, false));
    }

    public void setEnable(boolean enable) {
        if (mEnable != enable) {
            mEnable = enable;
            notifyDataSetChanged();
        }
    }

    static class VideoGoodsHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_face_value)
        TextView tvFaceValue;
        @BindView(R.id.tv_payment_price)
        TextView tvPaymentPrice;

        VideoGoodsHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
